home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / C de cerca / Codewarrior Lite / MacOS Support / Headers / ANSI Headers / stdlib.h < prev    next >
Text File  |  1995-12-29  |  4KB  |  149 lines

  1. /* stdlib.h standard header */
  2. #ifndef _STDLIB
  3. #define _STDLIB
  4. #ifndef _YVALS
  5. #include <yvals.h>
  6. #endif
  7.  
  8. #if __MWERKS__
  9. #pragma options align=mac68k
  10.  
  11. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  12. #pragma import on
  13. #endif
  14. #endif
  15.  
  16. #if __MWERKS__ && !defined(_INLINE_CPU_CALLS_) && __POWERPC__
  17. #define _INLINE_CPU_CALLS_ 1            /* on by default with PPC */
  18. #endif
  19.  
  20.         /* macros */
  21. #ifndef NULL
  22. #define NULL             _NULL
  23. #endif
  24. #define EXIT_FAILURE    _EXFAIL
  25. #define EXIT_SUCCESS    0
  26. #define MB_CUR_MAX    _Mbcurmax
  27. #define RAND_MAX    32767
  28.         /* type definitions */
  29. #ifndef _SIZET
  30. #define _SIZET
  31. typedef _Sizet size_t;
  32. #endif
  33. #ifndef _WCHART
  34. #define _WCHART
  35. typedef _Wchart wchar_t;
  36. #endif
  37. typedef struct {
  38.     int quot;
  39.     int rem;
  40.     } div_t;
  41. typedef struct {
  42.     long quot;
  43.     long rem;
  44.     } ldiv_t;
  45. typedef int _Cmpfun(const void *, const void *);
  46.         /* declarations */
  47. _EXTERN_C /* low-level functions */
  48. int atexit(void (*)(void));
  49. void exit(int);
  50. #if __MWERKS__
  51. int _atexit(void (*)(void));
  52. void _exit(int);
  53. #endif
  54. char *getenv(const char *);
  55. int system(const char *);
  56. _END_EXTERN_C
  57. _C_LIB_DECL
  58. void abort(void);
  59. #if __MWERKS__ && !__POWERPC__
  60. int abs(int);
  61. #endif
  62. void *bsearch(const void *, const void *, size_t, size_t,
  63.     _Cmpfun *);
  64. void *calloc(size_t, size_t);
  65. div_t div(int, int);
  66. void free(void *);
  67. #if __MWERKS__ && !__POWERPC__
  68. long labs(long);
  69. #endif
  70. ldiv_t ldiv(long, long);
  71. void *malloc(size_t);
  72. int mblen(const char *, size_t);
  73. size_t mbstowcs(wchar_t *, const char *, size_t);
  74. int mbtowc(wchar_t *, const char *, size_t);
  75. void qsort(void *, size_t, size_t, _Cmpfun *);
  76. int rand(void);
  77. void *realloc(void *, size_t);
  78. long strtol(const char *, char **, int);
  79. size_t wcstombs(char *, const wchar_t *, size_t);
  80. int wctomb(char *, wchar_t);
  81. double _Stod(const char *, char **, long);
  82. float _Stof(const char *, char **, long);
  83. int _Stoflt(const char *, char **, long[], int);
  84. long double _Stold(const char *, char **, long);
  85. unsigned long _Stoul(const char *, char **, int);
  86. extern char _Mbcurmax;
  87. extern unsigned long _Randseed;
  88. _END_C_LIB_DECL
  89.         /* inlines, for C++ */
  90. #ifdef __cplusplus
  91. inline double atof(const char *_S)
  92.     {return (_Stod(_S, 0, 0)); }
  93. inline int atoi(const char *_S)
  94.     {return ((int)_Stoul(_S, 0, 10)); }
  95. inline long atol(const char *_S)
  96.     {return ((long)_Stoul(_S, 0, 10)); }
  97. inline void srand(unsigned int _Seed)
  98.     {_Randseed = _Seed; }
  99. inline double strtod(const char *_S, char **_Endptr)
  100.     {return (_Stod(_S, _Endptr, 0)); }
  101. inline unsigned long strtoul(const char *_S, char ** _Endptr,
  102.     int _Base)
  103.     {return (_Stoul(_S, _Endptr, _Base)); }
  104. #if __MWERKS__ && __POWERPC__
  105. inline int abs(int x)        { return (__abs(x)); }
  106. inline long labs(long x)    { return (__labs(x)); }
  107. #endif
  108. #else
  109.         /* declarations and macro overrides, for C */
  110. double atof(const char *);
  111. int atoi(const char *);
  112. long atol(const char *);
  113. void srand(unsigned int);
  114. double strtod(const char *, char **);
  115. unsigned long strtoul(const char *, char **, int);
  116. #define atof(s)        _Stod(s, 0, 0)
  117. #define atoi(s)        (int)_Stoul(s, 0, 10)
  118. #define atol(s)        (long)_Stoul(s, 0, 10)
  119. #define srand(seed)    (void)(_Randseed = (seed))
  120. #define strtod(s, endptr)    _Stod(s, endptr, 0)
  121. #define strtoul(s, endptr, base)    _Stoul(s, endptr, base)
  122. #if __MWERKS__ && __POWERPC__
  123. int abs(int);
  124. long labs(long);
  125. #define abs(x)        __abs(x)
  126. #define labs(x)        __labs(x)
  127. #endif
  128. #endif /* __cplusplus */
  129.  
  130. #if __MWERKS__
  131. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  132. #pragma import reset
  133. #endif
  134.  
  135. #pragma options align=reset
  136. #endif
  137.  
  138. #endif /* _STDLIB */
  139.  
  140. /*
  141.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  142.  * Consult your license regarding permissions and restrictions.
  143.  */
  144.  
  145. /* Change log:
  146.  *94June04 PlumHall baseline
  147.  *94Oct07 Inserted MW changes.
  148.  */
  149.